﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>删除流程</title>
    <script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="../Comm/Gener.js" type="text/javascript"></script>
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <script src="../Scripts/layui/layui/layui.js" type="text/javascript"></script>
    <style>
        .layui-form {
            margin: 20px 20px 0;
            padding: 20px 0;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 5px 5px #eee;
        }
        .layui-form-label{
            padding: 9px 15px 9px 28px;
        }
        .btn-group {
            margin-left: 70%;
        }
        #TB_Doc:focus {
            border-color: #66afe9;
            outline: 0;
            -webkit-box-shadow: inset 0 0px 0px rgba(0,0,0,.075), 0 0 6px #6cbefe99;
            box-shadow: inset 0 0px 0px rgba(0,0,0,.075), 0 0 6px #6cbefe99;
        }
    </style>
    <script type="text/javascript">
        var fk_flow = GetQueryString("FK_Flow");
        var fk_node = GetQueryString("FK_Node");
        var workid = GetQueryString("WorkID");

        $(function () {
            layui.use(['form'], function () {
                Init();
                layui.form.render();
            });

        });

        function Init() {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("FK_Node", fk_node);
            handler.AddPara("WorkID", workid);
            var data = handler.DoMethodReturnString("DeleteFlowInstance_Init");
            if (data.indexOf("err@") != -1) {
                layer.alert(data);
                return;
            }

            if (data.length == 0 || data == "4") {
                return;
            }

            $('input[name="deleteWay"][value="' + data + '"]').attr("checked", true);
        }

        function DeleteFlow() {
            var doc = $("#TB_Doc").val();
            var deleteWay = $('input[name="deleteWay"]').filter(':checked').val();
            var isDeleteFlow = $('input[name="CB_IsDeleteSubFlow"]').filter(':checked').val(); 
            if (isDeleteFlow == undefined)
                isDeleteFlow = "0";

            if (doc == "" || doc.trim().length == 0) {
                layer.alert("请填写删除原因!");
                return;
            }

            if (deleteWay == "" || deleteWay == null || deleteWay == "undefined") {
                layer.alert("请选择删除方式!");
                return;
            }
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("FK_Node", fk_node);
            handler.AddPara("WorkID", workid);
            handler.AddPara("RB_DeleteWay", deleteWay);
            handler.AddPara("TB_Doc", doc);
            handler.AddPara("CB_IsDeleteSubFlow", isDeleteFlow);
            var data = handler.DoMethodReturnString("DeleteFlowInstance_DoDelete");

            if (data.indexOf("err@") != -1) {
                layer.alert(data);
                return;
            }

           // layer.alert("删除成功");
            CloseWindow(data);

           
        }
        function CloseWindow(data) {
            
            if (window.parent && typeof window.parent.returnWorkWindowClose == "function") {
                window.parent.returnWorkWindowClose(data);
            } else if (window.opener && typeof window.opener.returnWorkWindowClose == "function")
                window.opener.returnWorkWindowClose(data);

        }
    </script>
</head>
<body>
    <div class="layui-form">
        
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">删除原因</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入删除原因" rows="3" id="TB_Doc" name="TB_Doc" style="height: 100px; width: 90%; background-color: #f9f9f9; border-color: #cacaca; "></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">删除方式</label>
            <div class="layui-input-block">
                <input type="radio" name="deleteWay" value="1" title="逻辑删除" checked="" />
                <input type="radio" name="deleteWay" value="2" title="记录日志方式删除" />
                <input type="radio" name="deleteWay" value="3" title="彻底删除" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px !important; padding: 9px 15px 9px 8px;">是否删除子流程</label>
            <div class="layui-input-block">
                <input type="checkbox" id="CB_IsDeleteSubFlow" name="CB_IsDeleteSubFlow" lay-skin="switch" lay-text="是|否" value="1"/>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block btn-group">
                <button type="button" class="layui-btn" onclick="DeleteFlow()">删除流程</button>
                <button type="button" class="layui-btn layui-btn-normal" onclick="CloseWindow('取消')">取消</button>
            </div>
        </div>
    </div>

</body>
</html>
